function checkRecord(self){
  var id = $(self).attr("record_id");
  if ($(self).attr("checked")){
    var p = 0;
    for (var i in lids) {
      if (lids[i] == id) p = 1;
    }
    if (p == 0) lids.push(id);
  }else {
    for (var i = lids.length - 1; i >= 0 ; i--) {
      if (lids[i] == id) lids.splice(i,1);
    }
  }
}

//1-全选，2-不选，3-反选
function clickLnkSelect(self,type) {
  if (type == 1) {
    $(self).parent().parent().find('input[type=checkbox]').each(function(i,self){
      $(self).attr('checked',true);
      checkRecord(self);
    });;
  }else if (type == 2){
    $(self).parent().parent().find('input[type=checkbox]').each(function(i,self){
      $(self).attr('checked',false);
      checkRecord(self);
    });;
  //lids = [];
  }else {
    $(self).parent().parent().find('input[type=checkbox]').each(function(i,self){
      if ($(self).attr('checked')) $(self).attr('checked',false);
      else $(self).attr('checked',true);
      checkRecord(self);
    });
  }
}

function insertRecords(){
  if (lids.length == 0) {
    alert("请选择记录");
    return ;
  }
  var data = {};
  data['ids'] = lids;
  data['hy_id'] = $("#selHY").val();
  data['zy_id'] = $("#selZY").val();
  ajax.send(url+"/insertType",data,function(obj){
    alert(obj.data);
    window.location.href = url+'/doclist';
  });
}